package br.com.trabalho4.model.swing;

import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JPanel;

import br.com.trabalho4.model.shape.Shape;

public class JPaintPanel extends JPanel {
	private static final long serialVersionUID = -7176224212051016761L;

	private List<Shape> shapesList;
	private int zoom;
	
	public JPaintPanel() {
		this.shapesList = new ArrayList<Shape>();
		this.zoom = 1;
	}
	
	public void addShape(Shape s) {
		shapesList.add(s);
	}
	
	public void removeShape(Shape s) {
		shapesList.remove(s);
	}
	
	public void removeAllShapes() {
		shapesList.clear();
	}
	
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		Graphics gg = g.create();
		
		System.out.println("DESENHANDO...");
		
		for (Shape s : shapesList) {
			s.setZoom(zoom);
			s.draw(gg);
		}
		
		gg.dispose();
		
//		new Point(15, 10).draw(g);
//		new Point(30, 10).draw(g);
//		new Point(22, 20).draw(g);
		
//		new Line(new Point(15,10), new Point(200,100)).draw(g);
//		List<Line> edgeList = new ArrayList<Line>();
//		
//		edgeList.add(new Line(new Point(15, 10), new Point(30, 10)));
//		edgeList.add(new Line(new Point(22, 20), new Point(30, 10)));
//		edgeList.add(new Line(new Point(15, 10), new Point(22, 20)));
//		
//		new CustomShape(edgeList).draw(g);
		
//		new Line(new Point(15, 10), new Point(15, 30)).draw(g);
//		new Line(new Point(15, 30), new Point(30, 10)).draw(g);
//		new Line(new Point(30, 10), new Point(15, 10)).draw(g);
	}
	
	public void setZoom(int zoom) {
		this.zoom = zoom;
	}
}
